﻿using Org.BouncyCastle.Utilities.Encoders;
using System.Text;

namespace 加密算法
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //DSA
            // 生成密钥对
            var keys = DSAHelper.GenerateDSAKeyPair();
            byte[] message = Encoding.UTF8.GetBytes("爱游戏爱编程");
            // 加密
            byte[] encryptedBytes = DSAHelper.SignDSA(message, keys.Private);
            string encryptedStr = Hex.ToHexString(encryptedBytes);
            Console.WriteLine("Encrypted: " + encryptedStr);

            // 解密签名是否正确
            bool result = DSAHelper.VerifyDSA(message, encryptedBytes, keys.Public);
            Console.WriteLine("Decrypted: " + result);
        }
    }
}
